package com.ttmusic.utils;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.os.Environment;

/**
 * 自定义的LOG输出类  输出到 内部存储/TTmusic/logs/ 内  真机调试时用
 * @author wuchangyong
 *
 */
public class Logs {

	//日志根目录
	public static String LogRootPath = Environment.getExternalStorageDirectory().toString() 
			+ "/TTmusic/logs/";
	public static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
	public static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	public static void writeLog(String title, String content) {
		File f = new File(LogRootPath);
		if(!f.exists()) {
			f.mkdirs();
		}
		f = new File(LogRootPath + sdf1.format(new Date()) + ".log");
		Writer writer = null;
		try {
			writer = new FileWriter(f, true);
			writer.write("\r\n\r\n\r\n" + sdf2.format(new Date()) + "：" + title + "\r\n" + content);
			writer.flush();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
}
